package com.xiaoxiong.mami;

import com.xiaoxiong.mami.config.UserSecurityInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Administrator on 2017/7/25.
 */
@SpringBootApplication
public class Application extends WebMvcConfigurerAdapter{

    public static final String USER = "/user/*";
    public static final String USER_LONGIN = "/user/loginByPhoneAndPassword";
    public static final String USER_REGISTER = "/user/register";

    @Autowired
    UserSecurityInterceptor userSecurityInterceptor;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    String [] SECURITY_URL = {USER};
    String [] EXCLUDE_URL = {USER_LONGIN,USER_REGISTER};

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userSecurityInterceptor).addPathPatterns(SECURITY_URL).excludePathPatterns(EXCLUDE_URL);
    }

}
